package day15.test05;

import java.io.*;
import java.net.Socket;

/**
 * @author Xiao
 * @date 2021/8/9
 */
public class Client05 {
    /**
     * 5. 使用TCP完成数据的发送和接收
     *     发送端发送，接收端接收
     *     接收端回复，发送端接收
     */
    public static void main(String[] args) throws IOException {
        Socket so = new Socket("127.0.0.1",12321);
        OutputStream os = so.getOutputStream();
        os.write("我爱你。。。\r\n你爱我。。。\r\n蜜雪冰城甜蜜蜜。。。".getBytes());
        so.shutdownOutput();
        BufferedReader br = new BufferedReader(new InputStreamReader(so.getInputStream()));
        String s;
        while ((s = br.readLine()) != null) {
            System.out.println(s);
        }
        so.close();
    }
}
